package com.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.project.bean.SellCarBean;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ISellCarMapper extends BaseMapper<SellCarBean> {

    @Select("SELECT SUM(p.p_sellPrice*s.sc_num) FROM t_sellCar s,t_product p WHERE p.pk_productId =s.fk_productId AND s.fk_userId =#{userId}")
    @ResultType(Integer.class)
    public Integer getTotalPage(Integer userId);

    @Select("SELECT s.*,p.* FROM t_sellCar s,t_product p WHERE s.`fk_productId`=p.`pk_productId` AND s.`fk_userId`=#{userId}")
    @ResultMap("sellCarMap")
    List<SellCarBean> findByUserId(Integer userId);
}
